package simulations.factory;

import masses.FixedMass;
import masses.Mass;
import simulations.Entity;

import java.util.Scanner;

/**
 * Factory class for creating Masses
 * @author Zach Michaelov
 */
public class MassFactory {
    public static Mass fromScanner(Scanner line, Entity entity) {
        int id = line.nextInt();
        double x = line.nextDouble();
        double y = line.nextDouble();
        double mass = line.nextDouble();
        if (mass < 0) { // if mass is negative, then fixed mass
            return new FixedMass(id, x, y);
        }
        return new Mass(id, x, y, mass);
    }
}
